import java.util.ArrayList;
import java.util.Random;

//扑克牌管理：生成一副牌，随机抽一张牌
public class PokerManager {
    //pokers中存生成的牌
    ArrayList<Poker> pokers = new ArrayList<>();
    //扑克牌数字
    String[] number = {"2","3","4","5","6","7","8","9","10","J","Q","K","A"};
    //扑克牌花色
    String[] suit = {"♦","♣","♥","♠"};
    public PokerManager(){
        //生成52张扑克牌
        for(int i = 0; i< number.length;i++){
            for(int j = 0; j< suit.length;j++){
                PokerNumber numberObj = new PokerNumber(number[i], i);
                PokerSuit suitObj = new PokerSuit(suit[j],j );
                Poker poker = new Poker(numberObj,suitObj);
                //存入pokers中
                pokers.add(poker);
            }
        }
        //洗牌
        //Collections.shuffle(pokers);
    }
    //随机抽一张牌
    public Poker getPoker(){
        Random random = new Random();
        int index = random.nextInt(pokers.size());
        Poker poker= (Poker) pokers.get(index);
        pokers.remove(index);
        return poker;
    }
    //为每一个玩家发一张牌
    public void dealPoker(ArrayList<Player> players){
        for(int i = 0;i<players.size();i++){
            players.get(i).poker = getPoker();
        }
    }
}